package test

import (
	"gpt-api/framework/auther"
	"gpt-api/framework/db"
	"gpt-api/framework/did"
	"gpt-api/framework/ginplus"
	"gpt-api/pkg/model"

	"github.com/gin-gonic/gin"
)

type Handler struct {
	db  *db.DB
	did *did.DID
}

type returnData struct {
	VideoPath string `json:"video_path"`
}

func New(db *db.DB, auther auther.Auther) *Handler {
	return &Handler{db: db}
}

func (h *Handler) GetTest(c *gin.Context) error {
	err := (&model.Exchange{}).GenerateExchangeCode(h.db, 100)
	if err != nil {
		return ginplus.ReplyInternalError(c, err)
	}

	return ginplus.ReplyJSON(c, returnData{
		VideoPath: "success",
	})
}

func (h *Handler) PostTest(c *gin.Context) error {
	// 限制上传图片大小
	//c.Request.ParseMultipartForm(1 << 20)
	// 生成兑换码
	//exchange := model.Exchange{}
	err := (&model.Exchange{}).GenerateExchangeCode(h.db, 100)
	if err != nil {
		return ginplus.ReplyInternalError(c, err)
	}

	return ginplus.ReplyJSON(c, gin.H{
		"code": 0,
		"msg":  "success",
	})
}
